#pragma once
#include "cv.h"
#include "cv.h"
#include "highgui.h"
#include <math.h>
class QImage;
class CSquareFinder
{
public:
	CSquareFinder(void);
public:
	~CSquareFinder(void);

	void setImage(IplImage* pIPLImg)
	{
		img0 = pIPLImg;
		img = cvCloneImage( img0 );
	}

	void thresholdChanged(int ithresh)
	{thresh = ithresh >= 20 ? 20:ithresh;}

	IplImage* fetchData();
private:
	// returns sequence of squares detected on the image.
	// the sequence is stored in the specified memory storage
	CvSeq* findSquares4_( IplImage* img, CvMemStorage* storage );

	void drawSquares( IplImage* img, CvSeq* squares );

	int thresh ;
	IplImage* img ;
	IplImage* img0 ;
	CvMemStorage* storage ;
	CvPoint pt[4];
};
